package com.bua.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

public class GallaryAdpter extends BaseAdapter {

	String[] xiufutiType = { "缺失", "近中牙合支托", "远中牙合支托", "舌侧牙合支托", "近中三臂卡环",
			"远中三臂卡环", "近中半卡环", "远中半卡环", "RPI卡环", "RPA卡环", "T型卡环", "I型卡环",
			"U型卡环", "对半卡环", "隐形卡环", "舌侧带状卡环", "近中舌侧大连接体", "远中舌侧大连接体", "磁性固位体",
			"根帽", "太极扣", "冠内附着体（可扩展型号）", "冠外附着体（可扩展型号）", "套筒冠（可扩展材质种类）",
			"隐形义齿", "金属铸造冠", "烤瓷冠", "全瓷冠", "贴面", "嵌体" };
	int[] color = { Color.BLACK, Color.BLUE, Color.CYAN, Color.DKGRAY,
			Color.GRAY, Color.GREEN, Color.LTGRAY, Color.MAGENTA, Color.RED,
			Color.WHITE, Color.YELLOW+50 , Color.BLUE+50, Color.CYAN+50, Color.DKGRAY+50,
			Color.GRAY+50, Color.GREEN+50, Color.LTGRAY+50, Color.MAGENTA+50, Color.RED+50,
			Color.WHITE+50, Color.YELLOW+100, Color.BLUE+100, Color.CYAN+100, Color.DKGRAY+100,
			Color.GRAY+100, Color.GREEN+100, Color.LTGRAY+100, Color.MAGENTA+100, Color.RED+100,
			Color.WHITE+100};

	private Context mContext = null;
	private int[] mImageList = null;
	private IImageSetter mSetter = null;

	public GallaryAdpter(Context context, int[] ImageList,
			IImageSetter imgSetter) {
		super();
		mContext = context;
		mImageList = ImageList;
		mSetter = imgSetter;
	}

	@Override
	public int getCount() {
		// TODO 自动生成的方法存根
		if (mImageList == null)
			return 0;
		return mImageList.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO 自动生成的方法存根
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO 自动生成的方法存根
		return arg0;
	}

	@Override
	public View getView(final int arg0, View arg1, ViewGroup arg2) {
		// TODO 自动生成的方法存根
		Button btnImageItem = new Button(mContext);
		btnImageItem.setWidth(80);
		btnImageItem.setHeight(80);
		btnImageItem.setPadding(5, 0, 5, 0);
		btnImageItem.setText(xiufutiType[mImageList[arg0]]);
		btnImageItem.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO 自动生成的方法存根

				// Bitmap bitmap =
				// BitmapFactory.decodeFile(xiufutiType[mImageList[arg0]]);
				// ibtnContext.setImage(bitmap);
				//ibtnContext.setBackgroundColor(color[mImageList[arg0]]);
				mSetter.setImageSeg(0,"");
			}
		});
		return btnImageItem;
	}

}
